package com.cyzy.entity;

import java.time.LocalDateTime;

/**
 * 邮箱验证码实体类
 * @author LIGHT
 */
public class EmailVerificationCode {
    
    /**
     * 邮箱地址
     */
    private String email;
    
    /**
     * 验证码
     */
    private String code;
    
    /**
     * 过期时间
     */
    private LocalDateTime expireTime;
    
    /**
     * 验证码是否已使用
     */
    private boolean used;

    public EmailVerificationCode() {
    }

    public EmailVerificationCode(String email, String code, LocalDateTime expireTime) {
        this.email = email;
        this.code = code;
        this.expireTime = expireTime;
        this.used = false;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    public boolean isUsed() {
        return used;
    }

    public void setUsed(boolean used) {
        this.used = used;
    }
    
    /**
     * 检查验证码是否有效
     * @return 是否有效
     */
    public boolean isValid() {
        return !used && LocalDateTime.now().isBefore(expireTime);
    }
} 